<template>
    <ZkModalVue class="select-category" :title="title" :size="'sm'" :visible="visible" @cancel="handleCancel">
        <CategoryTreeVue v-if="visible" :type="type" :hasOper="false" :rootKey="rootKey" @selected="onSelected"></CategoryTreeVue>
    </ZkModalVue>
</template>
<script>
    import ZkModalVue from '@/appBase/ZkModal.vue';

    export default {
        name: "SelectCategory",
        components: {
            ZkModalVue,
            CategoryTreeVue: () => import('../CategoryTree.vue')
        },
        data() {
            return {
                title: '分类选择',
                pageLoading: false,
                visible: false,
                type: null
            }
        },
        methods: {
            /**
             * 显示
             * @param {Object} param
             * @param {Number} param.type 1-产教融合新闻 2-社区公共服务新闻 3-社群公共服务视频 4-资源库 5.章节
             */
            show(param) {
                this.type = param.type;
                this.rootKey = param.rootKey;
                if (this.type==5) {
                    this.title="选择章节";
                }
                this._onOk = param.onOk;
                this._onCancel = param.onCancel;
                this.visible = true;
            },
            handleCancel() {
                this.visible = false;
                if (this._onCancel) this._onCancel();
            },
            onSelected(item) {
                this.visible = false;
                if (this._onOk) this._onOk(item);
            }
        }
    }
</script>